<?php

namespace Pay\Model;
use Think\Model;
class LogModel extends Model {


  /**
 * 日志模型
 * @author
 */
private function getLevelStr($level)
	{
		switch ($level)
		{
		case 1:
			return 'DEBUG';
		break;
		case 2:
			return 'INFO';
		break;
		case 4:
			return 'WARN';
		break;
		case 8:
			return 'ERROR';
		break;
		default:

		}
	}
function Get_Date()
{
	return date ('Y-m-d');
}

function Get_Time()
{
	return date('H:i:s');
}
function Get_DateTime()
{
	$this->Get_Date." ".$this->Get_Time();
}
function write($message,$level='ERROR',$destination='') {
    $LOG_PATH = './';
    $LOG_FILE_SIZE = 100;
    $now = date('[ c ]');
    $type = $type?$type:3;
    // 文件方式记录日志
        if(empty($destination))
            $destination = $LOG_PATH.date('y-m-d').'.log';
        //检测日志文件大小，超过配置大小则备份日志文件重新生成
        if(is_file($destination) && floor($LOG_FILE_SIZE) <= filesize($destination) )
              rename($destination,dirname($destination).'/'.basename($destination).'-'.time().'.log');

   // error_log("{$now} {$level}: {$message}\r\n", $type,$destination );
    //clearstatcache();



}
}